package com.example.shushiyunsst.fragment.main.home.child.miner.sub

import android.os.Bundle
import android.view.View
import androidx.appcompat.widget.Toolbar
import com.example.library_common.adapter.JssBaseViewHolder
import com.example.library_common.album.utils.Utils
import com.example.library_common.base.SimpleListFragment
import com.example.library_common.bean.CommonBean
import com.example.shushiyunsst.R
import com.example.shushiyunsst.fragment.main.home.child.miner.bean.LiuSuiBean
import com.example.shushiyunsst.fragment.main.home.child.miner.bean.PlantTreeBean
import com.senon.modularapp.util.JssSpannableString
import ikidou.reflect.TypeBuilder
import java.lang.reflect.Type

/**
 * 流水
 * */
class LiuSuiFragment : SimpleListFragment<LiuSuiBean>(){

    companion object{
        fun newInstance(): LiuSuiFragment {
            val args = Bundle()
            val fragment = LiuSuiFragment()
            fragment.arguments = args
            return fragment
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        isAddDividerItemDecoration=false
        isEnableLoadMore=false
    }

    override fun initView(view: View) {
        super.initView(view)
        view.setBackgroundResource(R.drawable.bg_theme)
        mHeader.removeAllViews()
        addHeader(R.layout.comment_header_layout)
        val mToolbar:Toolbar=mHeader.findViewById(R.id.mToolbar)
        mToolbar.setTitle(R.string.liu_shui)
        mToolbar.setNavigationOnClickListener { onBackPressedSupport() }

        addHeader(R.layout.liu_sui_header_layout)
    }

    override fun getItemLayout()= R.layout.liu_sui_item_fragment

    override fun convertItem(helper: JssBaseViewHolder?, item: LiuSuiBean?) {
        val str0="您的"
        val str1="合伙人型能量星树"
        val str2="今日硕果累累，结出大量矿石 您及时摘取，收获颇丰。"
        helper?.setText(
            R.id.desc,
            JssSpannableString(_mActivity,"$str0$str1$str2")
                .first(str0)
                .textColor(R.color.PrimaryColor)
                .first(str1)
                .textColor(R.color.tab_text_normal)
                .first(str2)
                .textColor(R.color.PrimaryColor)
        )
    }

    override fun getListType(): Type {
        return TypeBuilder.newInstance(CommonBean::class.java)
            .beginSubType(List::class.java)
            .addTypeParam(LiuSuiBean::class.java).endSubType().build()
    }

    override fun netRequest() {
        val jsonFromRaw = Utils.getJsonFromRaw(_mActivity, R.raw.temp_fack_data)
        parseDate(jsonFromRaw)
    }
}